// --------------------------------------------------------------------------------------------------------------------
// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.
// --------------------------------------------------------------------------------------------------------------------

namespace WP7Contrib.View.Controls.DateTimePicker
{
    using System;

    public class YearDataSource : DataSource
    {
        // Methods
        /// <summary>
        /// Gets the relative to.
        /// </summary>
        /// <param name="relativeDate">The relative date.</param>
        /// <param name="delta">The delta.</param>
        /// <returns></returns>
        protected override DateTime? GetRelativeTo(DateTime relativeDate, int delta)
        {
            if ((0x641 == relativeDate.Year) || (0xbb8 == relativeDate.Year))
            {
                return null;
            }
            int year = relativeDate.Year + delta;
            return new DateTime(year, relativeDate.Month, Math.Min(relativeDate.Day, DateTime.DaysInMonth(year, relativeDate.Month)));
        }
    }
}